package com.yin;

public class Test {

    public static void main(String[] args) {

        Test test = new Test();

//        int i = 3201;
//
//        String iStr = String.valueOf(i);

//        System.out.println(iStr.length());

        int[] arr = {1, 12, 500, 90956, 754};

        int[][] arr2 ={{1, 2, 3},{4, 5}};

//        System.out.println(test.getMaxBit(arr));
//        Util.print("Pre append:", arr);
//
//        arr = test.appendChild(arr, 100);
//
//        Util.print("Post append:", arr);

//        int count = 0;
//        for(int i = 0; i < arr2.length; i++) {
//            for(int j = 0; j< arr2[i].length; j++) {
//                System.out.println("这是第" + (++count) + "次循环");
//            }
//        }

        System.out.println(test.getBitValue(10, 1));
    }

    private int getBitValue(int num, int bit) {

        int[] map = {1, 10, 100, 1000, 10000, 100000, 1000000};
        return (Math.abs(num) / map[bit - 1]) % 10;
    }

    private int[] appendChild(int[] arr, int value) {

        int[] result = new int[arr.length + 1];
        result[result.length - 1] = value;

        System.arraycopy(arr, 0, result, 0, arr.length);

        return result;
    }

    private int getMaxBit(int[] arr) {

        int maxBit = 0;

        for(int cur : arr) {

            if(String.valueOf(cur).length() > maxBit) maxBit = String.valueOf(cur).length();
        }

        return maxBit;
    }
}
